package com.sapitest.script.goodslisttest.paracheck;

import com.sapitest.imp.TestCases;
import com.sapitest.imp.TestData;
import com.sapitest.keywords.asserts.BaseAssert;
import com.sapitest.keywords.asserts.JSONAssert;
import com.sapitest.utils.ConfigFile;
import com.sapitest.utils.bean.Response;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
 * 接口/v1/goodslist参数countryCode校验
 */
public class CountryCodeTest {
    @BeforeClass
    public void beforeClass() {
    }

    @Test(description= "countryCode为null")
    public void testcase001(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),20);
        Response response = TestCases.testMyShoppingTrolley(20);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "countryCode为空")
    public void testcase002(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),21);
        Response response = TestCases.testMyShoppingTrolley(21);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "countryCode长度超过2")
    public void testcase003(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),22);
        Response response = TestCases.testMyShoppingTrolley(22);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "countryCode传入int类型")
    public void testcase004(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),23);
        Response response = TestCases.testMyShoppingTrolleyReplaceValue(23, "countryCode", 1);
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @Test(description= "countryCode不传")
    public void testcase005(){
        String exp = TestData.getExpResponseData(ConfigFile.getTestParameter("MY_SHOPPING_TROLLEY_TABLE"),24);
        Response response = TestCases.testMyShoppingTrolleyWithoutPara(24, "countryCode");
        BaseAssert.numEquals(response.getResponseCode(), 200);
        JSONAssert.jsonObjectEquals(response.getResponseBody(), exp);
    }

    @AfterClass
    public void afterClass() {
    }
}
